import { Application } from "mydog";

class ConnectorManager {

  private static _instance: ConnectorManager | undefined = undefined;
  public static getInstance(): ConnectorManager {
    if (!this._instance) {
      this._instance = new ConnectorManager();
    }
    return this._instance;
  }

  private constructor() { }

  private _app: Application = null as any;
  private _notNotifyUids: { [uid: number]: boolean } = {}; // 掉线后不通知Lobby的uid集合

  public init(app: Application) {
    this._app = app;
  }

  public addUid(uid: number) {
    this._notNotifyUids[uid] = true;
  }

  public isNeedNotify(uid: number) {
    const has = !!this._notNotifyUids[uid];
    if (has) {
      delete this._notNotifyUids[uid];
    }
    return !has;
  }
}

export default ConnectorManager.getInstance();
